package com.sl.au.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.sl.au.entity.User;
import com.sl.au.service.UserService;
import com.sl.au.entity.Account;
import com.sl.au.service.AccountService;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/ui/userInformationEdit")
public class UserInformationEditController extends BaseController{
    @Autowired
    UserService userService;
    @Autowired
    AccountService accountService;

    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView index(HttpServletRequest request) {
        ModelAndView modelAndView=createLayoutView("userInformationEdit/userInformationEdit");
        String name=request.getParameter("name");
        Account account=accountService.getAccountData(name);
        String userName=account.getUser().getName();
        String userSex=account.getUser().getSex();
        String userId=account.getUser().getId();
        modelAndView.addObject("id",userId);
        modelAndView.addObject("user",userName);
        modelAndView.addObject("sex",userSex);
        return modelAndView;

    }



}
